<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;

use cmf\controller\HomeBaseController;
use think\Db;

class IndexController extends HomeBaseController
{
    public function index()
    {
        $banner=Db::name('slide_item')->where("slide_id",1)->where('status',1)->order('list_order asc')->limit(0,4)->select();
        foreach ($banner as $k=>$v){
            $img="img".$k;
            $this->assign("{$img}",$v);
        }
        $product=Db::name("portal_post")->where('post_type',1)->where("post_status",1)->where("recommended",1)->order('create_time desc')->limit(0,6)->select();
        $list=array();
        foreach ($product as $k=>$v){
           // print_r($v['$v['post_title']']);exit;
            $more=json_decode($v['more'],true);
            if(strpos($more['thumbnail'],'http') === false) {
                $list[$k]['more']['thumbnail']="/public/upload/".$more['thumbnail'];
            }else{
                $list[$k]['more']['thumbnail']=$more['thumbnail'];
            }
            $list[$k]['post_title']=$v['post_title'];
            $list[$k]['post_excerpt']=$v['post_excerpt'];
            $list[$k]['id']=$v['id'];
        }
       // print_r($list);
        $this->assign("list", $list);
        return $this->fetch(':index');
    }
}
